Skip to content
This repository has been archived by the owner on Sep 1, 2020. It is now read-only.

Latest commit

 

History

History
15 lines (10 loc) · 681 Bytes

3.7.1 - Coroutine/Socket::__construct.md

File metadata and controls

15 lines (10 loc) · 681 Bytes

Coroutine\Socket::__construct

构造Coroutine\Socket对象。

function Coroutine\Socket::__construct(int $domain, int $type, int $protocol);

详情可参见man socket文档。

  • $domain:协议域,可使用AF_INETAF_INET6AF_UNIX
  • $type:类型,可使用SOCK_STREAMSOCK_DGRAMSOCK_RAW
  • $protocol:协议,IPPROTO_TCPIPPROTO_UDPIPPROTO_STCPIPPROTO_TIPC,可设置为0

构造方法会调用socket系统调用创建一个socket句柄。调用失败时会抛出Swoole\Coroutine\Socket\Exception异常。并设置$socket->errCode属性。可根据该属性的值得到系统调用失败的原因。